#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_list.py
# author:Jackiex
# datetime:2023/4/13 14:37
# software: PyCharm

"""
 Python的数据类型  list（列表）
"""

from random import randint

# 定义列表
# mylist = [1, 2, 3, 'a', 'b', 'c']
# print(mylist)
#
# print(mylist[0])
# print(mylist[3])

# for i in mylist:
#     print(i)

# print(type(mylist))

# 通过产生随机数，给列表赋值
# list = []
#
# for i in range(1,11):
#     list.append(randint(1,100))
#
# print(list)

'''
 练习1：从键盘上连续循环输入5个值(字符串)，存放到列表中
'''

# list = []

# 每次输入一个
# for s in range(1,6):
#     s = input("请输入一个字符串：")
#     list.append(s)

# for s in input("请依次输入5个字符串，空格隔开:").split():
#     list.append(s)
#
# print(list)

'''
 练习2：从键盘上连续循环输入5个整数，存放到列表中
'''
# list1 = []
#
# for s in input("请依次输入5个数:").split():
#     if (s.isdigit()):
#         s = int(s)
#         list1.append(s)
#
# print(list1)

'''
列表的相关操作
'''
# list1 = [11,22,33]
#
# list1.insert(2,4)
#
# print(list1)
#
# del list1[0]
#
# print(list1)
#
# list1.append(55)
# print(list1)

'''
列表元素排序
'''
# list1 = [11,22,33,12,45,9,3]
#
# list1.sort()
#
# print(list1)

'''
    输入5个同学的成绩,先找出最高分，然后打印出最低分；进行排序输出;进行添加新的数据操作; 打印出总分和平均值；
'''

# my_list = [1, 2, 3, 4, 5]
# sum = 0
# for i in my_list:
#     sum += i
# print(sum)  # 输出 15

# L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack']
# print(L[0:3])

'''
列表生成式(解析式)
'''
# li = list(range(1, 11))
# # li = [range(1, 11)]  # 无法打印出列表的值
# print(li)


from random import randint

list1 = [randint(1, 100) for _ in range(10)]

list2 = [x * x for x in range(1, 11)]

list3 = [x * x for x in range(1, 11) if x % 2 == 0]

print(list3)
